<?php
/**
 * 绩效管理模型
 */

namespace app\common\model;

use think\model\concern\SoftDelete;

class Performance extends Model
{
    use SoftDelete;
    public $softDelete = true;
    protected $name = 'performance';
    protected $autoWriteTimestamp = true;

    //可搜索字段
    protected $searchField = [];
    protected $whereField = ['staff_id', 'department_id', 'performance_time'];

    //绩效日期获取器
    public function getPerformanceTimeAttr($value)
    {
        return date('Y-m', $value);
    }


    //绩效日期修改器
    public function setPerformanceTimeAttr($value)
    {
        return strtotime($value);
    }


    //附件获取器
    public function getFileAttr($value)
    {
        return json_decode($value, true);
    }

    //附件修改器
    public function setFileAttr($value)
    {
        return json_encode($value);
    }

    //关联员工表
    public function staff()
    {
        return $this->belongsTo(Staff::class);
    }

    //关联职位表
    public function department()
    {
        return $this->belongsTo(Department::class);
    }

}
